const mongoose = require('mongoose')
mongoose.set('useFindAndModify', false)
const leaveSchema = mongoose.Schema({
  orderNo: String, // 申请单号
  applyType: Number, //申请类型 1.事假  2.调休  3.年假
  startTime: { type: Date, default: Date.now }, // 开始时间
  endTime: { type: Date, default: Date.now }, //结束时间
  applyUser: {
    // 申请人信息
    userId: String,
    userName: String,
    userEmail: String,
  },
  leaveTime: String, //休假时间
  reasons: String, // 休假原因
  auditUsers: String, // 完整审批人
  curAuditUserName: String, // 当前审批人
  auditFlows: [
    // 审批流
    {
      userId: String,
      userName: String,
      userEmail: String,
    },
  ],
  audiLogs: [
    {
      userId: String,
      userName: String,
      createTime: Date,
      remark: String,
      action: String,
    },
  ],
  applyState: {
    // 审批状态：1.待审批 2.审批中 3.审批拒绝 4.审批通过 5.作废
    type: Number,
    default: 1,
  },
  createTime: { type: Date, default: Date.now },
})
module.exports = mongoose.model('leave', leaveSchema, 'leave')
